import AppThemeMode from './AppThemeMode';
import { DStyles, DynamicStyleSheet, NormalizeStyles } from './DynamicStyleSheet';
import { useDynamicStyleSheet } from './UseDarkMode';



class StyleSheet<T extends DStyles> {
  params: DynamicStyleSheet<T>;

  constructor(props: T) {
    this.params = new DynamicStyleSheet(props);
  }

  // class组件使用
  get style(): NormalizeStyles<T> {
    return AppThemeMode.isDarkMode ? this.params.dark : this.params.light;
  }

  // funtion组件使用
  useDynamicStyle() {
    // eslint-disable-next-line react-hooks/rules-of-hooks
    return useDynamicStyleSheet(this.params);
  }
}

function create<T extends DStyles>(params: T) {
  return new StyleSheet(params);
}

export default { create };
